package com.example.myapplication.restructure;

public class ValueConvertUtils {
    public static int convertInt(Object o) {
        int result=1;
        if (o instanceof Integer) {
            result = (int) o;
        } else if (o instanceof Boolean) {
            result = (boolean) o ? 1 : 0;
        } else {

        }
        return result;
    }

    public static float convertFloat(Object o) {
        float result = 0.0f;
        if (o instanceof Integer) {
            result = (int) o;
        } else if (o instanceof Boolean) {
            result = (boolean) o ? 1.0f : 0.0f;
        } else if (o instanceof Float) {
            result = (float) o;
        } else if (o instanceof Double) {

        }
        return result;
    }

    public static boolean convertBoolean(Object o) {
        boolean result = false;
        if (o instanceof Integer) {
            result = (int) o > 0;
        } else if (o instanceof Boolean) {
            result = (boolean) o;
        } else if (o instanceof Double) {
            result = (double) o > 0;
        } else if (o instanceof Float) {
            result = (float) o > 0;
        }
        return result;
    }

}
